import { getFormFields } from '@/utils/formUtils'
import type { FormFieldConfig } from '@/types/form'

// 表格列配置
export const tableColumns = [
  {
    title: '診金類型',
    dataIndex: 'consultType',
  },
  {
    title: '分成方式',
    dataIndex: 'shareType',
  },
  {
    title: '分成',
    dataIndex: 'shareValue',
  },
  {
    title: '最後修改人',
    dataIndex: 'updatedBy',
  },
  {
    title: '最後修改時間',
    dataIndex: 'updatedAt',
  },
  {
    title: '操作',
    key: 'action',
    align: 'center',
  },
]

//表單
export const FormField: Record<string, FormFieldConfig> = {
  shareType: {
    label: '分成方式',
    type: 'radio', //作用是將一個值斷言為字面量類型
    placeholder: '請選擇分成方式',
    defaultValue: 1,
    options: [
      { label: '固定金額', key: 1 },
      { label: '按比例', key: 2 },
    ],
  },
  shareValue: {
    label: '分成',
    type: 'number', //作用是將一個值斷言為字面量類型
    placeholder: '請輸入分成',
    rules: [{ required: true, message: '請輸入分成', type: 'number' }],
    min:0,
    addonBefore: (formState: any) => (formState.shareType === 1 ? '$' : ''),
    addonAfter: (formState: any) => (formState.shareType === 2 ? '%' : ''),
  },
}


export const getSettingFieldConfig = (editFields?: string[]) => {
  return getFormFields(FormField, editFields)
}




